package com.zjitc.service;

import com.zjitc.common.ServerResponse;
import com.zjitc.pojo.*;
import com.zjitc.vo.PageModel;

import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
import java.util.concurrent.TimeoutException;

/**
 * Create By IntelliJ IDEA
 *
 * @author: myq
 * @create-Time: 2017/11/23  14:49
 */
public interface OrderService {

  /**
   * 分页查看订单
   * @param uid
   * @param pageid
   * @return
   */
  PageModel<Orders> findPageByUid(String uid, int pageid);

  /**
   * 从redis中查看订单
   * @param uid
   * @param filed
   * @return
   */
  Orders findOrderFromRedis(String uid, String filed);

  /**
   * 删除订单
   * @param uid
   * @param oid
   * @return
   */
  ServerResponse deleteorder(String uid, String oid);

  /**
   * 删除所有订单
   * @param uid
   * @return
   */
  int deleteAllorder(String uid);

  /**
   * 更新订单
   * @param user
   * @param order
   * @return
   * @throws SQLException
   */
  void update(User user, Orders order) throws SQLException;

  /**
   * 添加order到队列
   *
   * @param aid
   * @param total
   *@param user
   * @param caritems   @return
   * @throws InterruptedException
   */
  ServerResponse<Orders> addorder(String aid, Float total, User user, List<Caritem> caritems) throws InterruptedException;


  /**
   * 判断订单是否已经在数据库中
   * @param session
   * @throws IOException
   * @throws TimeoutException
   */
//  void judgeandupdate(HttpSession session) throws IOException, TimeoutException;

  /**
   * 找到所有的订单（后台管理）
   * @return
   */
  List<Orders> findAllOrder();
  /**
   * 查看历史所有订单（后台管理）
   * @return
   */
  List<Orders> findHistoryOrder();

  /**
   * 发货
   * @param oid
   */
  boolean shipments(String oid);

  /**
   * 查看快递
   * @param oid
   */
  void expcheck(String oid);

  /**
   * 收货
   * @param oid
   * @param user
   */
  void confirm(User user, String oid);

  /**
   * 检查库存
   * @param pid
   * @param count
   * @return
   */
  boolean hasinventory(String pid, String count);

  /**
   * 更新库存
   * @param orderitems
   */
  void updateinventory(List<Orderitem> orderitems,String type);


  /**
   * 判断订单是否已经被支付过了
   * @param oid
   * @param uid
   * @return
   */
  boolean checkOrder(String oid, String uid);


  /**
   * 后台管理删除订单  慎用
   *
   * @param s
   * @param oid
   * @return
   */
  boolean admindeleteOrder(String oid, String uid);

}
